#include <bits/stdc++.h>
using namespace std;
vector <int> c;
bool f(double p, int m)
{
for (auto x : c)
p -= (m + p) / x;
if (p < 0) return 0;
return 1;
}
int main()
{
int n, m;
cin >> n >> m;
vector <int> a(n);
vector <int> b(n);
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = 0; i < n; ++i) cin >> b[i];
c.resize(2 * n);
for (int i = 0; i < n - 1; ++i){
c[2 * i] = a[i];
c[2 * i + 1] = b[i + 1];
}
c[2 * n - 2] = a[n - 1];
c[2 * n - 1] = b[0];
if (find(c.begin(), c.end(), 1) != c.end()){
cout << -1;
}
else {
double left = 0, right = 2e9, eps = 1e-8, mid;
while (abs(right - left) > eps){
mid = (right + left) / 2;
if (f(mid, m)) right = mid;
else left = mid;
}
if (left <= 1e9) printf("%.7f", left);
else cout << -1;
}
return 0;
}
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |
Char Sum | Two Strings |
Anagrams | Prime Number |
Lexical Sorting Reloaded | 1514A - Perfectly Imperfect Array |
580A- Kefa and First Steps | 1472B- Fair Division |
996A - Hit the Lottery | MSNSADM1 Football |
MATCHES Playing with Matches | HRDSEQ Hard Sequence |
DRCHEF Doctor Chef | 559. Maximum Depth of N-ary Tree |
821. Shortest Distance to a Character | 1441. Build an Array With Stack Operations |
1356. Sort Integers by The Number of 1 Bits | 922. Sort Array By Parity II |
344. Reverse String | 1047. Remove All Adjacent Duplicates In String |